import {Injectable, Pipe, PipeTransform} from '@angular/core';
import { Route } from '@angular/router';

/**
 * Menu route pipe. Filters routes so it returns only those that can be displayed as menu item
 * 
 * Author: Sorin Spiru
 * Date: 13.01.2018
 */
@Pipe({
    name: 'menuRoute'
})
@Injectable()
export class MenuRoutePipe implements PipeTransform {
    transform(routes: Route[]) {
        return routes.filter(route => route.data && route.data.showAsMenu); 
    }
}